package team.pwy.mapper;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import team.pwy.pojo.entity.Order;

import java.util.List;

@Repository
public interface OrderMapper {

    @Select("select * from pwy.pwy_order where user_id =#{value} order by create_time desc")
    List<Order> findByUserId(Integer userId);

    @Select("select * from pwy.pwy_order where id = #{value}")
    Order findById(Integer id);

    Integer addOrder(Order order);

    @Update("update pwy.pwy_order set status = #{payStatus} where id = #{id};")
    Integer updateById(@Param("id") Integer id , @Param("payStatus") Integer payStatus);

    @Delete("delete from pwy.pwy_order where id = #{id} and user_id = #{userId}")
    Integer deleteByIdAndUserId(@Param("id") Integer id,@Param("userId") Integer userId);
    
    @Select("select * from pwy.pwy_order where number = #{value}")
    Order findByNumber(String number);

    @Update("update pwy.pwy_order set status = 10 where number = #{value}")
    Integer updateByNum(String number);
}
